home *** CD-ROM | disk | FTP | other *** search
/ Developer CD Series 1998 November: Tool Chest / Dev.CD Nov 98 TC.toast / Sample Code / Snippets / Development Tools & Languages / DTSCPlusLibrary / Sources / Tracer.cp < prev    next >
Encoding:
Text File  |  1993-01-14  |  1.9 KB  |  62 lines  |  [TEXT/MPS ]

  1. /* _________________________________________________________________________________________________________ //
  2.   Copyright © 1992 Apple Computer, Inc. All rights reserved.
  3.   Macintosh Developer Technical Support.C++ Macintosh Toolbox Framework.
  4.   Originator: Kent Sandvik
  5.   Date: Friday, July 10, 1992 10:14:13
  6.   Revision comments are at the end of this file.
  7.   ---
  8.   TTracer is an example of a stack/heap based tracing class, which could be
  9.   used for tracing memory leaks and keeping track of created objects
  10.   TTracer.cp contains the class body information for the initial class construction.
  11.   _________________________________________________________________________________________________________ */
  12.  
  13.  
  14. // Include files
  15. #ifndef _TRACER_
  16. #include "Tracer.h"
  17. #endif
  18.  
  19.  
  20. // _________________________________________________________________________________________________________ //
  21. // TTracer class member function implementations
  22.  
  23. //    CONSTRUCTORS & DESTRUCTORS
  24. #pragma segment Tracer                       
  25. TTracer::TTracer(const char* label,
  26.                  const char* file,
  27.                  int line) :
  28.     fLabel(label),
  29.     fFile(file),
  30.     fLine(line)
  31. // Default constructor.
  32. {
  33.     fReferenceCount++;
  34.  
  35.     cout << "File " << fFile << " ; Line " << fLine << "  #+++ constructor event in " << fLabel << " (reference count = " << fReferenceCount << ")\n";
  36. }
  37.  
  38.  
  39. #pragma segment Tracer
  40. TTracer::~TTracer()
  41. // Default destructor.
  42. {
  43.     fReferenceCount--;
  44.     cout << "File " << fFile << " ; Line " << fLine << "  #--- destructor  event in " << fLabel << " (reference count = " << fReferenceCount << ")\n";
  45. }
  46.  
  47.  
  48. // GLOBAL FUNCTIONS
  49. int TTracer::fReferenceCount = 0;                // initialize with zero value
  50.  
  51. // this will construct a global/universal tracer
  52. TTracer gGlobalTracer("gGlobalTracer",
  53.                       TRACEPOINT);
  54.  
  55.  
  56. // _________________________________________________________________________________________________________ //
  57.  
  58. /*    Change History (most recent last):
  59.   No        Init.    Date        Comment
  60.   1            khs        7/10/92        New file
  61. */
  62.